package edu.gatech.gui;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

import edu.gatech.presenters.DoctorsOrdersPresenter;
import edu.gatech.userclasses.Doctor;
import edu.gatech.userclasses.Patient;

public class DoctorsOrdersPanel {
	private static JTextField textField;
	private static JTextField textField_1;
	private static JTextField textField_2;
	private static JTextField textField_3;
	private static JTextField textField_4;
	private static JTextField textField_5;
	private static JCheckBox checkBox;
	private static Patient currentPatient;
	private static Doctor currentDoctor;
	public DoctorsOrdersPanel(Patient cur, Doctor curDoc){
		currentDoctor = curDoc;
		currentPatient = cur;
		JFrame drOrders = new JFrame("Doctors Orders Panel");
		
		MenuBar menu = new MenuBar (drOrders);
		drOrders.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        drOrders.setSize(600,480); 
        drOrders.getContentPane().setLayout(null);
        
        textField = new JTextField();
        textField.setEditable(false);
        textField.setText(currentPatient.getName());
        textField.setFont(new Font("Arial", Font.PLAIN, 10));
        textField.setColumns(10);
        textField.setBounds(124, 169, 166, 21);
        drOrders.getContentPane().add(textField);
        
        textField_1 = new JTextField();
        textField_1.setText("\r\n");
        textField_1.setFont(new Font("Arial", Font.PLAIN, 10));
        textField_1.setColumns(10);
        textField_1.setBounds(366, 169, 166, 21);
        drOrders.getContentPane().add(textField_1);
        
        textField_2 = new JTextField();
        textField_2.setFont(new Font("Arial", Font.PLAIN, 10));
        textField_2.setColumns(10);
        textField_2.setBounds(366, 201, 166, 21);
        drOrders.getContentPane().add(textField_2);
        
        textField_3 = new JTextField();
        textField_3.setFont(new Font("Arial", Font.PLAIN, 10));
        textField_3.setColumns(10);
        textField_3.setBounds(124, 201, 166, 21);
        drOrders.getContentPane().add(textField_3);
        
        checkBox = new JCheckBox("Follow up?");
        checkBox.setBounds(163, 232, 97, 23);
        drOrders.getContentPane().add(checkBox);
        
        textField_4 = new JTextField();
        textField_4.setText("\r\n");
        textField_4.setFont(new Font("Arial", Font.PLAIN, 10));
        textField_4.setColumns(10);
        textField_4.setBounds(125, 261, 166, 21);
        drOrders.getContentPane().add(textField_4);
        
        textField_5 = new JTextField();
        textField_5.setText("\r\n");
        textField_5.setFont(new Font("Arial", Font.PLAIN, 10));
        textField_5.setColumns(10);
        textField_5.setBounds(399, 233, 133, 21);
        drOrders.getContentPane().add(textField_5);
        
        JButton button = new JButton("Add Orders");
        button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				DoctorsOrdersPresenter presenter = new DoctorsOrdersPresenter(currentDoctor, currentPatient);
				boolean selected = checkBox.isSelected();
				presenter.addOrders(textField_2.getText(), textField_5.getText(), textField_3.getText(), 
						textField_4.getText(), textField_1.getText(), selected);
				
			}
		});
        button.setFont(new Font("Arial", Font.PLAIN, 10));
        button.setBounds(301, 261, 127, 21);
        drOrders.getContentPane().add(button);
        
        JButton btnCancel = new JButton("Cancel");
        btnCancel.setFont(new Font("Arial", Font.PLAIN, 10));
        btnCancel.setBounds(438, 261, 94, 21);
        drOrders.getContentPane().add(btnCancel);
        
        JLabel lblCurrentPatient = new JLabel("Current Patient:");
        lblCurrentPatient.setFont(new Font("Arial", Font.PLAIN, 10));
        lblCurrentPatient.setBounds(73, 43, 80, 14);
        drOrders.getContentPane().add(lblCurrentPatient);
        
        JLabel lblNewLabel = new JLabel(currentPatient.getName() +"\r\n");
        lblNewLabel.setFont(new Font("Arial", Font.BOLD, 14));
        lblNewLabel.setBounds(73, 68, 203, 14);
        drOrders.getContentPane().add(lblNewLabel);
        
        JLabel lblPatientName = new JLabel("Patient Name:");
        lblPatientName.setFont(new Font("Arial", Font.PLAIN, 10));
        lblPatientName.setBounds(50, 172, 68, 14);
        drOrders.getContentPane().add(lblPatientName);
        
        JLabel lblLabWork = new JLabel("Lab Work:");
        lblLabWork.setFont(new Font("Arial", Font.PLAIN, 10));
        lblLabWork.setBounds(72, 204, 46, 14);
        drOrders.getContentPane().add(lblLabWork);
        
        JLabel lblFollowUpInfo = new JLabel("Follow Up Info:");
        lblFollowUpInfo.setFont(new Font("Arial", Font.PLAIN, 10));
        lblFollowUpInfo.setBounds(50, 264, 77, 14);
        drOrders.getContentPane().add(lblFollowUpInfo);
        
        JLabel lblOtherInfo = new JLabel("Other Info:");
        lblOtherInfo.setFont(new Font("Arial", Font.PLAIN, 10));
        lblOtherInfo.setBounds(300, 172, 56, 14);
        drOrders.getContentPane().add(lblOtherInfo);
        
        JLabel lblMedications = new JLabel("Medications:");
        lblMedications.setFont(new Font("Arial", Font.PLAIN, 10));
        lblMedications.setBounds(299, 204, 67, 14);
        drOrders.getContentPane().add(lblMedications);
        
        JLabel lblFrequencyOfMed = new JLabel("Frequency of Med:");
        lblFrequencyOfMed.setFont(new Font("Arial", Font.PLAIN, 10));
        lblFrequencyOfMed.setBounds(300, 236, 107, 14);
        drOrders.getContentPane().add(lblFrequencyOfMed);
        
        JPanel panel = new JPanel();
        panel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Orders", TitledBorder.LEADING, TitledBorder.TOP, null, UIManager.getColor("Button.darkShadow")));
        panel.setBounds(26, 148, 520, 149);
        drOrders.getContentPane().add(panel);
        drOrders.setVisible(true);
	}

}
